home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Ken Long / PaletteAnim-c / Color Spectrum / colorSpectrum.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-04  |  1.3 KB  |  73 lines  |  [TEXT/KAHL]

  1. //# include <ColorToolbox.h>
  2. # include <Palettes.h>
  3. //# include <Color.h>
  4.  
  5.  
  6. # define BASE_RES_ID        400
  7. # define NIL_POINTER        0L
  8. # define MOVE_TO_FRONT        -1L
  9. # define CLUT_ID            130
  10. # define PALETTE_ID            1288
  11. # define SRC_USAGE            2
  12. # define SRC_TOLERANCE        0
  13. # define REMOVE_ALL_EVENTS    0
  14.  
  15.  
  16. WindowPtr        gHelloWindow;
  17. RGBColor        myRGB;    
  18. Point            *mouseLoc;
  19. int                x,y,c;
  20. PaletteHandle    gThePalette;
  21. CTabHandle        gTheCLUT;
  22.  
  23.  
  24.  
  25. /******************** Main ********************/
  26. main()
  27. {
  28.     ToolBoxInit();
  29.     WindowInit();
  30. }
  31.  
  32.  
  33.  
  34. /******************** ToolBoxInit ********************/
  35. ToolBoxInit()
  36.  
  37. {
  38.     InitGraf ( &qd.thePort );
  39.     InitFonts();
  40.     FlushEvents ( everyEvent,  0 );
  41.     InitWindows();
  42.     InitMenus();
  43.     TEInit();
  44.     InitDialogs( 0L );
  45.     InitCursor();
  46. }
  47.  
  48.  
  49. /******************** WindowInit ********************/
  50. WindowInit ()
  51. {    
  52.  
  53.     gHelloWindow = GetNewCWindow ( BASE_RES_ID, 0L, (WindowPtr)-1L );
  54.     SetPort ( gHelloWindow );
  55.     gTheCLUT = GetCTable ( CLUT_ID );
  56.     gThePalette = GetNewPalette ( PALETTE_ID );
  57.     CTab2Palette ( gTheCLUT, gThePalette, 2, 0);
  58.     SetPalette ( gHelloWindow, gThePalette, TRUE );
  59.     ActivatePalette ( gHelloWindow );
  60.     while (!Button())
  61.     {
  62.         y = 500;
  63.         for (c = 1; c < 255; c++ )
  64.         {
  65.             x++;
  66.             MoveTo ( x, y );
  67.             GetEntryColor ( gThePalette, c, &myRGB );
  68.             RGBForeColor ( &myRGB );
  69.             GetMouse ( mouseLoc );
  70.             LineTo ( x, 0 );
  71.         }    
  72.     }
  73. }